package com.tedu.api.io;

import java.io.File;
import java.io.FileFilter;
import java.io.IOException;

//作业2：提示--创建FileFilter接口--匿名内部类
public class HomeWork2 {
    public static void main(String[] args) throws IOException{
        File file=new File("."+File.separator+"API");
        System.out.println(file.getCanonicalPath());
        FileFilter ff=new FileFilter(){
            public boolean accept(File pathname) {
                String name= pathname.getName();
                System.out.println("过滤出来文件夹名字："+name);
                return name.startsWith("s");
            }
        };
        File[] subs=file.listFiles(ff);
        for (int i=0;i< subs.length;i++){
            System.out.println("所有文件和文件夹名："+subs[i].getName());
        }
    }
}



